package com.taxigang.client.uibinder;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;
import com.taxigang.client.facebook.FacebookApi;
import com.taxigang.client.micro.TaxiGangCreator;
import com.taxigang.client.ui.map.MapView.PanelType;
import com.taxigang.client.uibinder.TaxiGangPresenter.CreateJoinMode;

public class Login extends TaxiGangPanel {

	private static LoginUiBinder uiBinder = GWT.create(LoginUiBinder.class);

	interface LoginUiBinder extends UiBinder<Widget, Login> {
	}

//	@UiField Button fbLoginButton;
	@UiField Button cancelButton;
	@UiField Label fbLoginText;
	@UiField DivElement fbLoginButton;
	
	public Login() {
		initWidget(uiBinder.createAndBindUi(this));
		
		fbLoginText.setText(TaxiGangCreator.taxiGangConstants.loginUseingFB());
		cancelButton.setText(TaxiGangCreator.taxiGangConstants.cancel());
		cancelButton.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				// TODO store nickname
				taxiGangRoute.show(PanelType.SEARCH);
			}
		});
		fbLoginButton.setInnerHTML("<fb:login-button/>");

//		fbLoginButton.addClickHandler(new ClickHandler() {
//			
//			@Override
//			public void onClick(ClickEvent event) {
//				// TODO store nickname
//				TaxiGangPresenter.getInstance().login(CreateJoinMode.LOGIN, true);
//			}
//		});
	}
	
//	public void show(){
//		
////		fbLoginButton.setId("bookmark");
////		FacebookApi.parseFBML(fbLoginButton.getId()); 
//		super.show();
//	}
	
}
